package com.wc.alorithm_blue_bridge._数据结构.树状数组.热身操领队;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/6/30 1:22
 * @description https://www.lanqiao.cn/problems/18596/learning/?contest_id=193
 */
public class Main {
    /**
     * 树状数组 + 二分 + 离散化
     * 思路：
     * 需要知道当前插入的前面有多少谁的前缀和是大于等于sum / 2的, 谁就是老大
     * 然后他给的身高范围有点大, 那就只能离散化处理
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010, len = 0;
    static long[] tr = new long[N];
    static int[] a = new int[N];
    static int[] h = new int[N];
    static int[] c = new int[N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            h[i] = c[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }

        Arrays.sort(c, 1, n + 1);
        // 去重
        for (int i = 1; i <= n; i++) {
            if (c[len] != c[i]) c[++len] = c[i];
        }
        long s = 0;
        for (int i = 1; i <= n; i++) {
            int l = 1, r = len;
            while (l < r) {
                int mid = l + r >> 1;
                if (c[mid] >= h[i]) r = mid;
                else l = mid + 1;
            }
            add(l, a[i]);
            s += a[i];
            l = 1;
            r = len;
            while (l < r) {
                int mid = l + r >> 1;
                if (sum(mid) >= (s + 1) / 2) r = mid;
                else l = mid + 1;
            }
            out.println(c[l]);
        }
        out.flush();
    }

    static long sum(int x){
        long res = 0;
        for(int i = x; i >= 1; i -= lowbit(i)){
            res += tr[i];
        }
        return res;
    }

    static void add(int x, int c) {
        for (int i = x; i <= len; i += lowbit(i)) {
            tr[i] += c;
        }
    }

    static int lowbit(int x) {
        return x & -x;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
